package design_pattern.momento.test3;

/**
 * Created by WeiDingKuo on 2017/10/27 15:43
 */
public class Test {
    public static void main(String[] args) {
        Orignator orignator = new Orignator();
        CareTaker careTaker = new CareTaker();

        orignator.setName("a", careTaker);
        careTaker.saveMomento(orignator.createMomento());
        orignator.setName("b", careTaker);
        careTaker.saveMomento(orignator.createMomento());
        orignator.setName("c", careTaker);
        careTaker.saveMomento(orignator.createMomento());
        orignator.setName("d", careTaker);
        careTaker.saveMomento(orignator.createMomento());
        orignator.setName("e", careTaker);
        careTaker.saveMomento(orignator.createMomento());

        orignator.restoreMoment(careTaker.retrieveMomento(2));
        careTaker.removeDisabledMomento(2);
        System.out.println(orignator.getName());


        System.out.println("==========");
        orignator.setName("ff", careTaker);
        careTaker.saveMomento(orignator.createMomento());
        orignator.setName("dd", careTaker);
        careTaker.saveMomento(orignator.createMomento());
        orignator.setName("ee", careTaker);

        orignator.printName(careTaker);
    }
}
